package com.tz.farmer.controller;

import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.service.UserLoginService;
import com.tz.farmer.so.FarmerUserInfoSo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@Api("登录-web")
@RestController
@RequestMapping("/login")
public class LoginController {


    @Resource
    private UserLoginService userLoginService;

    /**
     * 登录接口
     * @param so - username,password
     *      里面有登陆方式的loginType   - 登录方式(1: username-账号,password-密码
     *                                          2: username-手机号,password-验证码)
     * @return - 返回账号信息给前端
     */
    @PostMapping("/in")
    @ApiOperation("登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userAccount", value = "账号", dataType = "string", defaultValue = "", required = true),
            @ApiImplicitParam(name = "password", value = "密码", dataType = "string", defaultValue = "", required = true)
    })
    public ResultEx login(@RequestBody FarmerUserInfoSo so) {
        return  userLoginService.login(so);
    }



}
